package com.vone.view;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;

import com.vone.util.SizeCalculationUtil;

/**
 * 主面板
 * @author wd
 *
 */
public class MianWindowJFrame extends JFrame {
	private static final long serialVersionUID = 1L;

	//标题面板
	private TitleJPanelView titleJPanel = null;
	//主内容面板
	private MainJPanelView mainJPanelView = null;
	//计算工具
	private SizeCalculationUtil sizeUtil = new SizeCalculationUtil();
	private static MianWindowJFrame mianWindowJFrame = null;
	public MianWindowJFrame(){
		this.setLayout(null);
		this.setSize(sizeUtil.getW(900),sizeUtil.getH(650));//设置默认窗口大小
		Dimension displaySize = Toolkit.getDefaultToolkit().getScreenSize();//获得显示器大小对象
		Dimension frameSize = this.getSize();//获得窗口大小对象
		if(frameSize.width > displaySize.width)
			frameSize.width = displaySize.width;//窗口的宽度不能大于显示器的宽度
		if(frameSize.height > displaySize.height)
			frameSize.height = displaySize.height;//窗口的高度不能大于显示器的高度
		//设置窗口居中显示器显示
		this.setLocation(
				(displaySize.width - frameSize.width)/2,
				(displaySize.height - frameSize.height)/2
		);
		
		
		titleJPanel = new TitleJPanelView(this);
		titleJPanel.setBounds(sizeUtil.getX(0), sizeUtil.getY(0), sizeUtil.getW(900), sizeUtil.getH(48));
		
		mainJPanelView = new MainJPanelView();
		mainJPanelView.setBounds(sizeUtil.getX(0), sizeUtil.getY(48), sizeUtil.getW(900), sizeUtil.getH(650));
		
		//把两个主面板添加上来
		this.getContentPane().add(titleJPanel);
		this.getContentPane().add(mainJPanelView);
		
		this.setUndecorated(true);//是否出现标题栏(true=不出现,false=出现,不设置默认false)
		this.setResizable(false);//设置窗口是否可以调整大小(true=可以调整,false=不可调整,默认为true)
		this.setVisible(true);//使窗口可见(true=可见,false=不可见,不设置默认false)
		mianWindowJFrame = this;
	}
	
	public static MianWindowJFrame getMianWindowJFrame() {
		return mianWindowJFrame;
	}

	public static void main(String[] args) {
		new MianWindowJFrame();
	}
	
}
